package com.sl.au.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

/**
 * 单元网格实体
 * 
 * @author HE GUANG CHUAN
 *
 */
@Entity
@Table(name = "sl_wcsi_gridArea")
public class GridAreaInfo extends Root {

	// 单元网格编码
	private String gridIdentify;
	// 单元网格面积
	private Double gridArea;
	
	//权重
	private Double gridScale;
	
	private String gridName;
	// 单元网格初始化时间
	// 单元网格状态
	@ManyToOne()
	@JoinColumn(name = "optionStateId")
	private Option gridState;
	// 单元网格备注
	private String gridMemo;
	// 单元网格ObjectId
	private String gridToArcGisObjectId;
	// 单元网格所属区域id
	// private String areaId;
	@ManyToOne()
	@JoinColumn(name = "areaId")
	private Division division;
	
	@OneToMany(mappedBy = "gridInfo", fetch = FetchType.EAGER)
	@JsonManagedReference
    private List<GridAreaDetailInfo> details;
	
	// 单元网格类型
	@ManyToOne()
	@JoinColumn(name = "optionTypeId")
	private Option typeOpt;
	// 单元网格初始化时间
	private Date gridInitTime;
	@JsonBackReference
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name = "sl_wcsi_user_grid", joinColumns = { @JoinColumn(name = "grid_id") }, inverseJoinColumns = {
			@JoinColumn(name = "user_id") })
	private Set<User> users = new HashSet<>();

	public String getGridIdentify() {
		return gridIdentify;
	}

	public String getGridName() {
		return gridName;
	}

	public void setGridName(String gridName) {
		this.gridName = gridName;
	}

	public void setGridIdentify(String gridIdentify) {
		this.gridIdentify = gridIdentify;
	}

	public Double getGridArea() {
		return gridArea;
	}

	public void setGridArea(Double gridArea) {
		this.gridArea = gridArea;
	}

	public Option getGridState() {
		return gridState;
	}

	public void setGridState(Option gridState) {
		this.gridState = gridState;
	}

	public String getGridMemo() {
		return gridMemo;
	}

	public void setGridMemo(String gridMemo) {
		this.gridMemo = gridMemo;
	}

	public String getGridToArcGisObjectId() {
		return gridToArcGisObjectId;
	}

	public void setGridToArcGisObjectId(String gridToArcGisObjectId) {
		this.gridToArcGisObjectId = gridToArcGisObjectId;
	}

	public Division getDivision() {
		return division;
	}

	public void setDivision(Division division) {
		this.division = division;
	}

	public Option getTypeOpt() {
		return typeOpt;
	}

	public void setTypeOpt(Option typeOpt) {
		this.typeOpt = typeOpt;
	}

	public Date getGridInitTime() {
		return gridInitTime;
	}

	public void setGridInitTime(Date gridInitTime) {
		this.gridInitTime = gridInitTime;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public Double getGridScale() {
		return gridScale;
	}

	public void setGridScale(Double gridScale) {
		this.gridScale = gridScale;
	}

	public List<GridAreaDetailInfo> getDetails() {
		return details;
	}

	public void setDetails(List<GridAreaDetailInfo> details) {
		this.details = details;
	}
	
}
